package com.ruoyi;

import com.ruoyi.common.utils.DateUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class MyTest {
    public static void main(String[] args) {

        String percent="66.60%";
        percent = percent.replace("%","");
        Float f = Float.valueOf(percent) / 100;
        BigDecimal decimal = new BigDecimal(f);
        decimal = decimal.setScale(4, BigDecimal.ROUND_HALF_UP);


        System.out.println();


//        BigDecimal a;
//        BigDecimal b;
//        a = new BigDecimal(66.6666);
//        b = new BigDecimal(100);
////        System.out.print(a.divide(b, 4, RoundingMode.HALF_UP));
//
//
//        System.out.println(calcRate(a,b));

//        System.out.println(DateUtils.dateTimeNow(DateUtils.YYYY));
//        try {
//            getWeek();
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        System.out.println(2/4);
//        geneHtml();
//        geneAlpMonthly();

    }

    public static void getWeek() throws ParseException {
        String today = "2019-12-29";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = format.parse(today);
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.setTime(date);
        System.out.println(calendar.get(Calendar.WEEK_OF_YEAR));

    }
    public static String calcRate(BigDecimal fenzi, BigDecimal fenmu) {
        BigDecimal multiplyNum = new BigDecimal(100);
        BigDecimal result = fenzi.multiply(multiplyNum).divide(fenmu, 2, RoundingMode.HALF_UP);

        return result + "%";
    }

    public static void geneHtml() {
        for (int j = 1; j<=12; j++) {
            String i ="";
            if (j<10) {
                i = "0"+j;
            } else {
                i = ""+j;
            }
            System.out.println("                {\n" +
                    "                    field : 'm"+i+"Budget', \n" +
                    "                    title : '第"+i+"月预算'\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    field : 'm"+i+"Predict', \n" +
                    "                    title : '第"+i+"月预测'\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    field : 'm"+i+"Actual', \n" +
                    "                    title : '第"+i+"月实际'\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    field : 'm"+i+"FinishrateB', \n" +
                    "                    title : '第"+i+"月完成率(预算)'\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    field : 'm"+i+"FinishrateP', \n" +
                    "                    title : '第"+i+"月完成率(预测)'\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    field : 'm"+i+"Remainsum', \n" +
                    "                    title : '第"+i+"月余额'\n" +
                    "                },");
        }
    }

    public static void geneAlpMonthly() {
        for (int j = 1; j<=12; j++) {
            String i ="";
            if (j<10) {
                i = "0"+j;
            } else {
                i = ""+j;
            }

            System.out.println("   /** 第"+i+"月预算 */\n" +
                    "    @Excel(name = \"第"+i+"月预算\")\n" +
                    "    public BigDecimal m"+i+"Budget;\n" +
                    "\n" +
                    "    /** 第"+i+"月预测 */\n" +
                    "    @Excel(name = \"第"+i+"月预测\")\n" +
                    "    public BigDecimal m"+i+"Predict;\n" +
                    "\n" +
                    "    /** 第"+i+"月实际 */\n" +
                    "    @Excel(name = \"第"+i+"月实际\")\n" +
                    "    public BigDecimal m"+i+"Actual;\n" +
                    "\n" +
                    "    /** 第"+i+"月完成率（实际/预算） */\n" +
                    "    @Excel(name = \"第"+i+"月完成率（预算）\", readConverterExp = \"实际/预算\")\n" +
                    "    public String m"+i+"FinishrateB;\n" +
                    "\n" +
                    "    /** 第"+i+"月完成率（实际/预测） */\n" +
                    "    @Excel(name = \"第"+i+"月完成率（预测）\", readConverterExp = \"实际/预测\")\n" +
                    "    public String m"+i+"FinishrateP;\n" +
                    "\n" +
                    "    /** 第"+i+"月余额 */\n" +
                    "    @Excel(name = \"第"+i+"月余额\")\n" +
                    "    public BigDecimal m"+i+"Remainsum;");
        }
    }
}
